package cn.edu.hunau.oop.day03;

import org.junit.Test;

import java.util.Arrays;
import java.util.Random;

/**
 * @author hb
 * @date 2025-08-06 16:04:37
 */
public class CardTest {
    @Test
    public void test01(){
        //实例化一个黑桃3
        Card c1=new Card(0,0);
        System.out.println(c1);

        Card c2=new Card(Card.SUIT_HEITAO, Card.RANK_3);
        System.out.println(c2);


        Card c3=new Card(Card.SUIT_NULL, Card.RANK_QUEUEN);
        System.out.println(c3);
    }

    public Card[] newCards(){
        Card [] cards=new Card[54];
        int index=0;
        for(int rank=Card.RANK_3;rank<=Card.RANK_2;rank++){
            for(int suit=Card.SUIT_HEITAO;suit<=Card.SUIT_FANGKUAI;suit++){
                cards[index++]=new Card(suit, rank);
            }
        }
        //大小王
        cards[index++]=new Card(Card.SUIT_NULL, Card.RANK_QUEUEN);
        cards[index++]=new Card(Card.SUIT_NULL, Card.RANK_KING);

        //乱序
        Random r=new Random();
        for(int i=cards.length-1;i>0;i--){
            int j=r.nextInt(i);
            Card temp=cards[i];
            cards[i]=cards[j];
            cards[j]=temp;
        }


        return cards;
    }



    @Test
    public void test02(){

        Player [] players=new Player[3];
        players[0]=new Player("张飞");
        players[1]=new Player("关羽");
        players[2]=new Player("刘备");

        Card[] cards = newCards();
        for(int i=0;i<cards.length;i++){
            players[i%3].addCard(cards[i]);
        }

        for(Player p:players){
            System.out.println(p);
        }
    }
}
